/* 
 * File:   CAN_I.h
 * Author: aravelomanantsoa@gmail.com
 */

#ifndef CAN_I_H
#define	CAN_I_H

#ifdef	__cplusplus
extern "C" {
#endif

#include <libpcan.h>

#define CAN_DEVICE_NODE "/dev/pcan32"

#define V1_ID (0x101)
#define V2_ID (0x102)
#define V3_ID (0x103)
#define V4_ID (0x104)
#define BATTERIE_ID (0x106)
#define FREINAGE_ID (0x100)
#define VITESSE_ID (0x107)
#define FIN_DE_COURSE_DROITE_ID (0x108)
#define FIN_DE_COURSE_GAUCHE_ID (0x109)
#define DIRECTION_ID (0x10A)

#define TRUE (1)
#define FALSE (0)

#define CANNOT_OPEN_CAN_DEVICE (1)
#define CANNOT_READ_CAN_MSG (2)
#define CANNOT_SEND_REMOTE_FRAME (3)
#define CANNOT_SEND_DATA_FRAME (4)

typedef unsigned char bool;

typedef enum {
	V1 = 0,
	V2 = 10,
	V3 = 20,
	V4 = 30,
	V5 = 40,
	V6 = 50,
	V7 = 60,
	V8 = 70,
	V9 = 80,
	V10 = 90
} VITESSE;

typedef enum {
	D1 = 0,
	D2 = 5,
	D3 = 10,
	D4 = 15,
	D5 = 20,
	D6 = 25,
	D7 = 30,
	D8 = 35,
	D9 = 40,
	D10 = 45,
	D11 = 50,
	D12 = 55,
	D13 = 60,
	D14 = 65,
	D15 = 70,
	D16 = 75,
	D17 = 80,
	D18 = 85,
	D19 = 90,
	D20 = 95
} DIRECTION;

typedef enum {
	FIN_DE_COURSE_GAUCHE, FIN_DE_COURSE_DROITE
} FIN_DE_COURSE;

int readBatterie(int *batterie);
int readVitesse(int vitesse[]);
int updateVitesse(VITESSE v);
int freinage();
int fin_de_course(FIN_DE_COURSE f, BYTE *fin_de_sourse);
int updateDirection(DIRECTION d);

#ifdef	__cplusplus
}
#endif

#endif	/* CAN_I_H */

